﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Page.master" AutoEventWireup="true" Inherits="Order_Models" Codebehind="Order_Models.aspx.cs" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HtmlTitle" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ResultsPaneHeaderText" runat="Server">
    <script src="js/jquery.ui.combobox.js" type="text/javascript"></script>
    <style type="text/css">
	.ui-combobox {
		position: relative;
		display: inline-block;
	}
	.ui-button {
		position: absolute;
		top: 0;
		bottom: 0;
		margin-left: -1px;
		padding: 0;
		/* adjust styles for IE 6/7 */
		*height: 1.7em;
		*top: 0.1em;  
	}
	.ui-autocomplete-input {
		margin: 0;
		padding: 0.3em;
	}
	</style>
    <script type="text/javascript">
        $(function () {
            $('#nuovo').hide();
            $('#showNew').click(function () {
                $('#nuovo').toggle('slow', function () {
                    // Animation complete.
                    if ($('#showNew').val() == "Nuovo") {
                        $('#showNew').val("Annulla");
                    }
                    else {
                        $('#showNew').val("Nuovo");
                    }
                });
            });

          
                         $('#<%=ddFornitori.ClientID %>').append(
                            $('<option></option>').val("").html("")
                         );
                         $('#<%=ddFornitori.ClientID %>').combobox();

                         $('#<%=ddArticoli.ClientID %>').append(
                            $('<option></option>').val("").html("")
                         );
                         $('#<%=ddArticoli.ClientID %>').combobox();
        });
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ResultsPane" runat="Server">
    <div style="float: right">
        <input type="button" id="showNew" class="ui-widget ui-state-default ui-corner-all ui-button-text-only"
            value="Nuovo" />
    </div>
    <div style="float: left">
        Fornitore:
        <asp:DropDownList ID="ddFornitori" runat="server" DataTextField="Fornitore" DataValueField="id">
        </asp:DropDownList>
    </div>
    <div style="text-align: center">
        Articoli:
        <asp:DropDownList ID="ddArticoli" runat="server" DataTextField="descrizione" DataValueField="id">
        </asp:DropDownList>
    </div>
    <div id="nuovo">
        <div style="text-align: right">
            <asp:Button ID="btnFiltra" Text="Filtra" runat="server" CssClass="ui-widget ui-state-default ui-corner-all ui-button-text-only"
                OnClick="btnFiltra_Click" />
        </div>
        <asp:GridView ID="dispo" runat="server" DataKeyNames="id" AutoGenerateColumns="false"
            AllowPaging="true" PageSize="10" Width="80%" OnRowCommand="Associa">
            <Columns>
                <asp:BoundField HeaderText="Cod" DataField="CodArt" />
                <asp:BoundField HeaderText="Art" DataField="descrizione" />
                <asp:BoundField HeaderText="Prezzo" DataField="PrezzoUnitario" />
                <asp:BoundField HeaderText="U.M." DataField="DescUnitaMisura" />
                <asp:BoundField HeaderText="Iva" DataField="Iva" />
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:ImageButton ID="btnLink" runat="server" ImageUrl="Images/apply.png" CommandName="Associa"
                            CommandArgument='<%# Eval("id") %>' />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <asp:GridView ID="gvAssociati" runat="server" DataKeyNames="id" AutoGenerateColumns="false"
            AllowPaging="true" PageSize="10" Width="80%" OnRowCommand="DeAssocia">
            <Columns>
                <asp:BoundField DataField="id" Visible="false" />
                <asp:BoundField HeaderText="Cod" DataField="CodArt" />
                <asp:BoundField HeaderText="Art" DataField="descrizione" />
                <asp:BoundField HeaderText="Prezzo" DataField="PrezzoUnitario" />
                <asp:BoundField HeaderText="U.M." DataField="DescUnitaMisura" />
                <asp:BoundField HeaderText="Iva" DataField="Iva" />
                <asp:TemplateField HeaderText="Quantità">
                    <ItemTemplate>
                        <asp:TextBox ID="txtQTA" runat="server"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:ImageButton ID="btnLink" runat="server" ImageUrl="Images/delete.png" CommandName="DeAssocia"
                            CommandArgument='<%# Eval("id") %>' />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <div>
            Nome Modello :
            <asp:TextBox ID="nomeNew" runat="server" MaxLength="50" /><asp:RequiredFieldValidator
                ID="RequiredFieldValidator1" runat="server" ErrorMessage="* Obbligatorio" ControlToValidate="nomeNew"
                ValidationGroup="NuovoModello"></asp:RequiredFieldValidator><br />
            Descrizione :
            <asp:TextBox ID="descrizioneNew" runat="server" MaxLength="50" TextMode="MultiLine"
                Rows="5" Columns="20"></asp:TextBox>
            <asp:Button ID="btnSave" Text="Salva" runat="server" CssClass="ui-widget ui-state-default ui-corner-all ui-button-text-only"
                OnClick="SalvaModello" ValidationGroup="NuovoModello" />
        </div>
    </div>
    <div id="Modelli">
        <asp:GridView ID="gvModelli" runat="server" AllowSorting="true" AllowPaging="true"
            AutoGenerateColumns="false" OnRowCommand="gvModelliCommand" OnPageIndexChanging="gvModelli_PageIndexChanging"
            OnSorting="gvModelli_Sorting" Width="80%">
            <Columns>
                <asp:BoundField DataField="nome" HeaderText="Nome" />
                <asp:BoundField DataField="descrizione" HeaderText="Descrizione" />
                <asp:BoundField DataField="dataCreazione" DataFormatString="{0:dd/MM/yyyy}" HeaderText="Creato" />
                <asp:TemplateField HeaderText="Elimina">
                    <ItemTemplate>
                        <asp:ImageButton ID="btnDel" runat="server" ImageUrl="Images/Icon_Cancel.png" CommandName="Elimina"
                            CommandArgument='<%# Eval("id") %>' AlternateText="Elimina Modello" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Converti">
                    <ItemTemplate>
                        <asp:ImageButton ID="btnConvert" runat="server" ImageUrl="Images/Icon_Clone.png" CommandName="Convert"
                            CommandArgument='<%# Eval("id") %>' AlternateText="Converti Modello in Ordine" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Modifica"> 
                    <ItemTemplate>
                        <a href='ModelDetail.aspx?t=<%# Eval("id") %>'><img src="Images/details.gif" alt="Modifica Modello" /> </a>
                        
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
    </div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="TasksPaneHeaderText" runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="TasksPane" runat="Server">
</asp:Content>
